using System;
using System.Collections.Generic;
using System.Text;

namespace PSE.Hosting.Management.Common
{
    /// <summary>
    /// A factory to control the instances of a class to access the Service Hoster's
    /// management services.
    /// </summary>
    public class ServiceFactory
    {
        private static volatile ServiceFactory _factoryInstance;
        private static volatile IServices _serviceInstance;

        /// <summary>
        /// Returns an instance of the ServiceFactory.
        /// </summary>
        public static ServiceFactory Instance
        {
            get
            {
                if (_factoryInstance == null)
                    _factoryInstance = new ServiceFactory();

                return _factoryInstance;
            }
        }

        /// <summary>
        /// Reutns an instance of the WCF services.
        /// </summary>
        /// <returns></returns>
        public IServices GetService()
        {
            if (_serviceInstance == null)
                _serviceInstance = new WcfServices();

            return _serviceInstance;
        }
    }
}
